package GUI;

import java.io.IOException;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.GregorianCalendar;
import java.util.zip.Inflater;

import javax.swing.JPanel;

import logic.Loan;
import logic.Member;
import logic.Message;

import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;
import javax.swing.JButton;


import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.SystemColor;
import javax.swing.UIManager;

public class Loan_Report extends JPanel{
	private Client_GUI parent;
	private JTextField textFieldAveragehot;
	private JTextField textFieldMedianhot;
	private JTextField textFieldavgReg;
	private JTextField textFieldmedReg;
	
	public Loan_Report(final Client_GUI parent,Message msg) {
		setBackground(UIManager.getColor("inactiveCaption"));
		this.parent = parent;
		this.setSize(Client_GUI.MAIN_WIDTH, Client_GUI.MAIN_HEIGHT);
		setLayout(null);
		
		
		ArrayList<String> stat_hot = new ArrayList<String>();
		stat_hot=(ArrayList<String>) msg.GetMessageData().get(0);
		ArrayList<String> stat_reg= new ArrayList<String>();
		stat_reg=(ArrayList<String>) msg.GetMessageData().get(1);
		ArrayList<String> data= new ArrayList<String>();
		data=(ArrayList<String>) msg.GetMessageData().get(2);
		
		JLabel lblLoanReport = new JLabel("Loan Report");
		lblLoanReport.setForeground(Color.RED);
		lblLoanReport.setFont(new Font("Tahoma", Font.BOLD, 20));
		lblLoanReport.setBounds(331, 25, 137, 40);
		add(lblLoanReport);
		
		JPanel panel = new JPanel();
		panel.setBorder(new LineBorder(new Color(0, 0, 0), 2, true));
		panel.setBounds(28, 76, 369, 378);
		add(panel);
		panel.setLayout(null);
		
		JLabel lblNewLabel = new JLabel("Hot Books");
		lblNewLabel.setFont(new Font("Tahoma", Font.BOLD, 15));
		lblNewLabel.setBounds(127, 11, 95, 22);
		panel.add(lblNewLabel);
		
		JLabel lblAveragehot = new JLabel("Average:");
		lblAveragehot.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblAveragehot.setBounds(49, 56, 81, 22);
		panel.add(lblAveragehot);
		
		textFieldAveragehot = new JTextField(data.get(0));
		textFieldAveragehot.setBounds(182, 57, 127, 22);
		panel.add(textFieldAveragehot);
		textFieldAveragehot.setColumns(10);
		
		JLabel lblMedian = new JLabel("Median:");
		lblMedian.setFont(new Font("Tahoma", Font.BOLD, 13));
		lblMedian.setBounds(49, 89, 81, 22);
		panel.add(lblMedian);
		
		textFieldMedianhot = new JTextField(data.get(1));
		textFieldMedianhot.setColumns(10);
		textFieldMedianhot.setBounds(182, 90, 127, 22);
		panel.add(textFieldMedianhot);
		
		JLabel lblDays = new JLabel("0 Days:");
		lblDays.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblDays.setBackground(new Color(240, 240, 240));
		lblDays.setBounds(49, 165, 59, 22);
		panel.add(lblDays);
		
		JLabel lblDays_1 = new JLabel("1 Days:");
		lblDays_1.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblDays_1.setBackground(SystemColor.menu);
		lblDays_1.setBounds(49, 198, 70, 22);
		panel.add(lblDays_1);
		
		JLabel lblDays_2 = new JLabel("2 Days:");
		lblDays_2.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblDays_2.setBackground(SystemColor.menu);
		lblDays_2.setBounds(49, 232, 59, 22);
		panel.add(lblDays_2);
		
		JLabel lblDays_3 = new JLabel("3 Days:");
		lblDays_3.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblDays_3.setBackground(SystemColor.menu);
		lblDays_3.setBounds(49, 265, 59, 22);
		panel.add(lblDays_3);
		
		JLabel lblDays_4 = new JLabel("4+ Days:");
		lblDays_4.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblDays_4.setBackground(SystemColor.menu);
		lblDays_4.setBounds(49, 298, 59, 22);
		panel.add(lblDays_4);
		
		JLabel LBL1h = new JLabel(stat_hot.get(0));
		LBL1h.setFont(new Font("Tahoma", Font.PLAIN, 13));
		LBL1h.setBounds(127, 165, 59, 19);
		panel.add(LBL1h);
		
		JLabel LBL2h = new JLabel(stat_hot.get(1));
		LBL2h.setFont(new Font("Tahoma", Font.PLAIN, 13));
		LBL2h.setBounds(127, 203, 59, 19);
		panel.add(LBL2h);
		
		JLabel LBL3h = new JLabel(stat_hot.get(2));
		LBL3h.setFont(new Font("Tahoma", Font.PLAIN, 13));
		LBL3h.setBounds(127, 237, 59, 19);
		panel.add(LBL3h);
		
		JLabel LBL4h = new JLabel(stat_hot.get(3));
		LBL4h.setFont(new Font("Tahoma", Font.PLAIN, 13));
		LBL4h.setBounds(127, 270, 59, 19);
		panel.add(LBL4h);
		
		JLabel LBL5h = new JLabel(stat_hot.get(4));
		LBL5h.setFont(new Font("Tahoma", Font.PLAIN, 13));
		LBL5h.setBounds(127, 303, 59, 19);
		panel.add(LBL5h);
		
		JLabel label_8 = new JLabel("%");
		label_8.setFont(new Font("Tahoma", Font.BOLD, 12));
		label_8.setBounds(194, 165, 18, 22);
		panel.add(label_8);
		
		JLabel label_9 = new JLabel("%");
		label_9.setFont(new Font("Tahoma", Font.BOLD, 12));
		label_9.setBounds(196, 198, 18, 22);
		panel.add(label_9);
		
		JLabel label_10 = new JLabel("%");
		label_10.setFont(new Font("Tahoma", Font.BOLD, 12));
		label_10.setBounds(196, 232, 18, 22);
		panel.add(label_10);
		
		JLabel label_11 = new JLabel("%");
		label_11.setFont(new Font("Tahoma", Font.BOLD, 12));
		label_11.setBounds(196, 265, 18, 22);
		panel.add(label_11);
		
		JLabel label_12 = new JLabel("%");
		label_12.setFont(new Font("Tahoma", Font.BOLD, 12));
		label_12.setBounds(196, 298, 18, 22);
		panel.add(label_12);
		
		JPanel panel_1 = new JPanel();
		panel_1.setLayout(null);
		panel_1.setBorder(new LineBorder(new Color(0, 0, 0), 2, true));
		panel_1.setBounds(420, 76, 363, 378);
		add(panel_1);
		
		JLabel lblRegularBooks = new JLabel("Regular Books");
		lblRegularBooks.setFont(new Font("Tahoma", Font.BOLD, 15));
		lblRegularBooks.setBounds(112, 11, 127, 22);
		panel_1.add(lblRegularBooks);
		
		JLabel label_1 = new JLabel("Average:");
		label_1.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_1.setBounds(49, 56, 81, 22);
		panel_1.add(label_1);
		
		textFieldavgReg = new JTextField(data.get(2));
		textFieldavgReg.setColumns(10);
		textFieldavgReg.setBounds(182, 57, 127, 22);
		panel_1.add(textFieldavgReg);
		
		JLabel label_2 = new JLabel("Median:");
		label_2.setFont(new Font("Tahoma", Font.BOLD, 13));
		label_2.setBounds(49, 89, 81, 22);
		panel_1.add(label_2);
		
		textFieldmedReg = new JTextField(data.get(3));
		textFieldmedReg.setColumns(10);
		textFieldmedReg.setBounds(182, 90, 127, 22);
		panel_1.add(textFieldmedReg);
		
		JLabel lblDays_5 = new JLabel("0-3 Days:");
		lblDays_5.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblDays_5.setBackground(SystemColor.menu);
		lblDays_5.setBounds(37, 158, 80, 22);
		panel_1.add(lblDays_5);
		
		JLabel lblDays_6 = new JLabel("4-7 Days:");
		lblDays_6.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblDays_6.setBackground(SystemColor.menu);
		lblDays_6.setBounds(37, 191, 80, 22);
		panel_1.add(lblDays_6);
		
		JLabel lblDays_7 = new JLabel("8-10 Days:");
		lblDays_7.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblDays_7.setBackground(SystemColor.menu);
		lblDays_7.setBounds(37, 225, 80, 22);
		panel_1.add(lblDays_7);
		
		JLabel lblDays_8 = new JLabel("11-14 Days:");
		lblDays_8.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblDays_8.setBackground(SystemColor.menu);
		lblDays_8.setBounds(37, 258, 80, 22);
		panel_1.add(lblDays_8);
		
		JLabel lblDays_9 = new JLabel("14+ Days:");
		lblDays_9.setFont(new Font("Tahoma", Font.BOLD, 12));
		lblDays_9.setBackground(SystemColor.menu);
		lblDays_9.setBounds(37, 291, 80, 22);
		panel_1.add(lblDays_9);
		
		JLabel LBL1r = new JLabel(stat_reg.get(0));
		LBL1r.setFont(new Font("Tahoma", Font.PLAIN, 13));
		LBL1r.setBounds(139, 158, 59, 19);
		panel_1.add(LBL1r);
		
		JLabel LBL2r = new JLabel(stat_reg.get(1));
		LBL2r.setFont(new Font("Tahoma", Font.PLAIN, 13));
		LBL2r.setBounds(139, 196, 59, 19);
		panel_1.add(LBL2r);
		
		JLabel LBL3r = new JLabel(stat_reg.get(2));
		LBL3r.setFont(new Font("Tahoma", Font.PLAIN, 13));
		LBL3r.setBounds(139, 230, 59, 19);
		panel_1.add(LBL3r);
		
		JLabel LBL4r = new JLabel(stat_reg.get(3));
		LBL4r.setFont(new Font("Tahoma", Font.PLAIN, 13));
		LBL4r.setBounds(139, 263, 59, 19);
		panel_1.add(LBL4r);
		
		JLabel LBL5r = new JLabel(stat_reg.get(4));
		LBL5r.setFont(new Font("Tahoma", Font.PLAIN, 13));
		LBL5r.setBounds(139, 296, 59, 19);
		panel_1.add(LBL5r);
		
		JLabel label_21 = new JLabel("%");
		label_21.setFont(new Font("Tahoma", Font.BOLD, 12));
		label_21.setBounds(221, 288, 18, 22);
		panel_1.add(label_21);
		
		JLabel label_22 = new JLabel("%");
		label_22.setFont(new Font("Tahoma", Font.BOLD, 12));
		label_22.setBounds(221, 255, 18, 22);
		panel_1.add(label_22);
		
		JLabel label_23 = new JLabel("%");
		label_23.setFont(new Font("Tahoma", Font.BOLD, 12));
		label_23.setBounds(221, 222, 18, 22);
		panel_1.add(label_23);
		
		JLabel label_24 = new JLabel("%");
		label_24.setFont(new Font("Tahoma", Font.BOLD, 12));
		label_24.setBounds(221, 188, 18, 22);
		panel_1.add(label_24);
		
		JLabel label_25 = new JLabel("%");
		label_25.setFont(new Font("Tahoma", Font.BOLD, 12));
		label_25.setBounds(219, 155, 18, 22);
		panel_1.add(label_25);
		
		JButton btnNewButton = new JButton("Done");
		btnNewButton.setFont(new Font("Tahoma", Font.BOLD, 14));
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
				Home home = new Home(parent,parent.client.publicMessages);
				VerifyDialog verify = new VerifyDialog(parent, home,false);

			}
		});
		btnNewButton.setBounds(357, 471, 103, 32);
		add(btnNewButton);
		
		

		
		
	}

	
	

}
